Skip to content

ConfigurableParam: reject malformed container fields, drop redundant parseSet#63

Merged
f3sch merged 1 commit into
f3sch:cfg/dynamicfrom
sawenzel:cfg/dynamic-improvements
Jun 25, 2026
Merged

ConfigurableParam: reject malformed container fields, drop redundant parseSet#63
f3sch merged 1 commit into
f3sch:cfg/dynamicfrom
sawenzel:cfg/dynamic-improvements

Conversation

@sawenzel

Copy link
Copy Markdown

Stacked on top of AliceO2Group#15525 (cfg/dynamic) — this PR targets that branch, so the diff shown here is only the follow-up changes, not the container support itself.

Three follow-up improvements found while reviewing AliceO2Group#15525, all confined to ContainerParser and its tests:

1. Reject malformed container fields instead of silently dropping them

split() discarded empty fields, so a stray delimiter was swallowed:

  • "[1,,3]" parsed to a 2-element vector with no error (element count silently corrupted).
  • "key:" dropped the empty map value.

split() now keeps empty tokens, so they are rejected by parseScalar / the map-syntax check and surface as a parse error. The empty-container case ("[]" / "{}") is still short-circuited by the callers before split() runs, so well-formed input is unaffected.

2. Remove the redundant parseSet branch (single-pass parsing)

Every non-map Container already satisfies SequenceContainer, so the parseSet dispatch branch was reached for all sequence and set types and re-parsed the string into a throwaway std::vector before copying element-by-element; the separate else if constexpr (Container<T>) branch was unreachable. parseSequence inserts at end(), which std::set / std::unordered_set accept just as well, so all non-map containers now share one single-pass path. The now-unused HasPushBack concept is removed.

3. Re-enable test cleanup

ConfigurableParam_Container_FileIO_ROOT left test_config.root on disk (the std::remove was commented out); re-enabled to restore test isolation.

Tests

Adds regression coverage:

  • set / unordered_set / list / deque parsing through the unified parseSequence path (incl. set de-duplication);
  • rejection of empty tokens in both sequence and map parsing.

Note on error severity (intentionally unchanged)

Container parse failures remain non-fatal (logged), which matches the existing scalar setValue behaviour (it already swallows scalar parse errors to std::cerr). This PR does not change that contract — it only stops malformed input from being silently accepted as a different value.


Verification: the changed parser logic was extracted into a standalone C++20 program and confirmed to compile (g++ -std=c++20 -Wall -Wextra) and behave correctly; full build + boost-test runs are left to CI.

🤖 Generated with Claude Code

…parseSet

Follow-up hardening on top of the std-container ConfigurableParam support.

1. split() no longer silently drops empty fields. A stray delimiter such as
   "[1,,3]" previously parsed to a 2-element vector with no error, and "key:"
   collapsed an empty map value away. Both now produce an empty token that is
   rejected by parseScalar / the map-syntax check, so malformed configuration
   surfaces as an error instead of corrupting element counts. The empty
   container case ("[]" / "{}") is still short-circuited by the callers before
   split() runs, so well-formed input is unaffected.

2. Removed the redundant parseSet() branch (and the now-unused HasPushBack
   concept). Every non-map Container already satisfies SequenceContainer, so the
   parseSet dispatch was reached for all sequence and set types and re-parsed the
   string into a throwaway std::vector before copying element-by-element.
   parseSequence inserts at end(), which std::set / std::unordered_set accept
   just as well, so all non-map containers now share a single, single-pass path.

3. Re-enabled cleanup of test_config.root in ConfigurableParam_Container_FileIO_ROOT
   (the std::remove was left commented out), restoring test isolation.

Adds regression tests: set/unordered_set/list/deque parsing through the unified
parseSequence path (incl. set de-duplication), and rejection of empty tokens in
both sequence and map parsing.

Note: container parse failures remain non-fatal (logged), matching the existing
scalar setValue behaviour; this commit does not change that contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@f3sch f3sch merged commit c76cfef into f3sch:cfg/dynamic Jun 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants